package org.matchergen.examples.command;

public class Service {
	private ICommandExecutor commandExecutor;

	public void printMessage() {
		PrintCommand command = new PrintCommand("Hallo Welt!");

		commandExecutor.executeCommand(command);

		LogCommand logCommand = new LogCommand("printing 'Hallo Welt!'");

		commandExecutor.executeCommand(logCommand);
	}

	public int doAddition(int a, int b) {
		AddCommand command = new AddCommand(a, b);

		commandExecutor.executeCommand(command);

		LogCommand logCommand = new LogCommand(String.format("addiere %d und %d", a, b));

		commandExecutor.executeCommand(logCommand);

		return command.getSum();
	}

	public ICommandExecutor getCommandExecutor() {
		return commandExecutor;
	}

	public void setCommandExecutor(ICommandExecutor commandExecutor) {
		this.commandExecutor = commandExecutor;
	}
}
